home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1994 / MacHack 1994.toast / MacHack™ 1987-1994 / MacHack™ '91 / Hacks '91 / Æ RPC Stub Compiler / examples.rpc next >
Encoding:
Text File  |  1991-06-17  |  2.8 KB  |  92 lines  |  [TEXT/MPS ]

  1. //
  2. //
  3. //        This file is an example of the rpc stub compiler
  4. //
  5. //
  6. //    Notixe that whenever a # sign is discovered everything from it to the end of it's line is 
  7. //        included in the output file
  8. //        
  9.  
  10. #include <aliases.h>
  11.  
  12. /*
  13.  *
  14.  *        The following is an example showing all the different types of parameter passing
  15.  *            and what sort of real parameters things get converted to in the stubs
  16.  *
  17.  */
  18.  
  19. short fred ('abcd' : 'defg') ('long' a[],                             // becomes     - long *a, unsigned long a_count
  20.                              struct b *b,                             //              struct b *b
  21.                              list of float c,                         //              float *c, unsigned long c_count
  22.                              list of (long d, short e) 'QQQQ');        //              long d, short e
  23. //
  24. //
  25. //        Which ends up looking like:
  26. //
  27. //    For the client            pascal OSErr fred(AEAddressDesc *server, 
  28. //                                              short *result, 
  29. //                                              long *a, unsigned long a_count, 
  30. //                                              struct b *b, 
  31. //                                              float *c, unsigned long c_count, 
  32. //                                              long d, short e);
  33. //
  34. //
  35. //    For the server            pascal OSErr fred_SERVER(short *result, 
  36. //                                              long *a, unsigned long a_count, 
  37. //                                              struct b *b, 
  38. //                                              float *c, unsigned long c_count, 
  39. //                                              long d, short e);
  40. //
  41.  
  42.  
  43.  
  44. //
  45. //
  46. //    here are some stub declarations for the core events for things that only handle aliases
  47. //
  48. //
  49.  
  50.  
  51. core_open_doc(kCoreEventClass:kAEOpenDocuments) (list of typeAlias THINGS keyDirectObject);
  52.  
  53. core_print_doc(kCoreEventClass:kAEPrintDocuments) (list of typeAlias THINGS keyDirectObject);
  54.  
  55. core_open_app(kCoreEventClass:kAEOpenApplication) (list of typeAlias THINGS keyDirectObject);
  56.  
  57. core_quit_app(kCoreEventClass:kAEQuitApplication) ();
  58.  
  59. //
  60. //    for example core_open_doc ends up as 'pascal OSErr core_open_doc(AEAddressDesc *server, AliasHandle *THINGS, unsigned long THINGS_count);
  61. //
  62.  
  63.  
  64. //
  65. //    Here are some stub declarations for the same things with fsspecs ... (commented out here because you don't want to declare 2 handlers for the same event)
  66. //
  67.  
  68. //core_open_doc_fs(kCoreEventClass:kAEOpenDocuments) (list of typeFSS THINGS keyDirectObject);
  69.  
  70. //core_print_doc_fs(kCoreEventClass:kAEPrintDocuments) (list of typeFSS THINGS keyDirectObject);
  71.  
  72. //core_open_app_fs(kCoreEventClass:kAEOpenApplication) (list of typeFSS THINGS keyDirectObject);
  73.  
  74. //
  75. //    for example core_open_doc_fs ends up as 'pascal OSErr core_open_doc_fs(AEAddressDesc *server, FSSpec *THINGS, unsigned long THINGS_count);
  76. //
  77.  
  78. //
  79. //    finally here are some examples of the options keywords, firstly using the server/client options to
  80. //    create a server that gets FSSpecs and a client that sends aliases, also set the send_timeout to be 400 ticks
  81. //
  82.  
  83. option server -client send_timeout = "400";
  84.  
  85. test_open_app_alias('test':kAEOpenApplication) (list of typeAlias THINGS keyDirectObject);
  86.  
  87. option -server client;
  88. test_open_app_fs('test':kAEOpenApplication) (list of typeFSS THINGS keyDirectObject);
  89.  
  90. option server client;
  91.  
  92.